﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Org.Kaka.CsmsUtil.DataEI.Import
{
    /// <summary>
    /// Excel import
    /// </summary>
    public class ExcelImport : ImportBase, IImport, Base.IDataSources
    {
        string excelPuth;
        string xmlTempLatePuth;
        ExcelDataSources excelDataSources;
        ExcelHelper excelHelper = new ExcelHelper();
        public ExcelImport()
        {
            ImportDataSource = excelDataSources;
        }

        #region GET/SET
        public string ExcelPuth
        {
            get { return excelPuth; }
            set { excelPuth = value; }
        }
        public string XmlTempLatePuth
        {
            get { return xmlTempLatePuth; }
            set { xmlTempLatePuth = value; }
        }
        public ExcelDataSources ExcelDataSources
        {
            get { return excelDataSources; }
            set { excelDataSources = value; }
        }
        #endregion

        #region 数据接口
        public string GetDSPuth()
        {
            return excelPuth;
        }

        public Base.DataSourcesType GetDSType()
        {
            return Base.DataSourcesType.EXCEL;
        }

        public string GetXMLTemplatePuth()
        {
            return XmlTempLatePuth;
        }
        #endregion

        #region 实现接口方法
        public bool Verification()
        {
            //throw new NotImplementedException();

            return false;
        }

        public void ProcessingMessage()
        {
            throw new NotImplementedException();
        }

        public System.Xml.XmlDocument LoadXmlTemplate(Base.IDataSources importDataSources)
        {
            try
            {
                Xml.XmlHepler xmlHeper = new Xml.XmlHepler();
                xmlHeper.XmlPuth = importDataSources.GetXMLTemplatePuth();
                return xmlHeper.GetXmlDocument();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public bool DoImport()
        {
            string connString = excelHelper.ExcelConnString(this.excelDataSources.ExcelVersion, ExcelPuth);
            return false;
        } 
        #endregion

    }

}
